import os
import pandas as pd
from shutil import copytree, copyfile, rmtree
from collections import defaultdict


def merge_single_code(src_path, dst_path):
    if not os.path.exists(src_path):
        return
    if not os.path.exists(dst_path):
        copytree(src_path, dst_path)
        return
    
    for f in os.listdir(src_path):
        copyfile(os.path.join(src_path, f), os.path.join(dst_path, f))
    return

def merge_dataset(src_path, dst_path):
    for code in os.listdir(src_path):
        print(code)
        merge_single_code(os.path.join(src_path, code), os.path.join(dst_path, code))


src_p_list = [
              r'/data2/autorepair/ruanzhifeng/autorepair_t7_10/t10_SD/add/SDrepair_AA_365F1_10x_20250616170603/Images'
            ]

dst_p = r'/data2/autorepair/ruanzhifeng/autorepair_t7_10/t10_SD/add/365F1/Images'

for src_p in src_p_list:
    merge_dataset(src_p, dst_p)
